﻿using AntMovement.Core.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace AntMovement.Core.Entity
{
    [Serializable]
    public class AxisParameter
    {
        #region 回零参数 

        /// <summary>
        /// 回原点起始速度
        /// </summary>
        public double Low_Vel { get; set; } = 10;

        /// <summary>
        /// 回原点运行速度
        /// </summary>
        public double High_Vel { get; set; } = 20;

        /// <summary>
        /// 设置回原点加速时间
        /// </summary>
        public double Tacc { get; set; } = 0.1;

        /// <summary>
        /// 减速时间回原点参数保留值，默认为0，回零偏置
        /// </summary>
        public double Tdec { get; set; } = 0.1;
        /// <summary>
        /// 回零目标速度
        /// </summary>
        public double HomeTargetSpeed { get; set; } = 0.1;
        public CustomZeroModeType CustomZeroMode { get; set; }
        #endregion

        #region 回零模式 smc_set_homemode
        /// <summary>
        /// 回原点方向 true正方向 false负方向
        /// </summary>
        public bool Home_dir { get; set; }
        /// <summary>
        /// 回原点速度模式 默认值=1
        /// </summary>
        public double Vel_Mode { get; set; } = 1;
        /// <summary>
        /// 回原点模式
        /// </summary>
        public ushort Mode { get; set; } = 0;
        /// <summary>
        /// 回零计数源，0：指令位置计数器，1：编码器计数器
        /// 当原点模式Mode=4时，回原点速度模式将固定为低速回原点
        /// </summary>
        public ushort Source { get; set; } = 0;
        #endregion

        #region 单轴速度曲线S段
        /// <summary>
        /// 保留参数，固定值为0
        /// </summary>
        public ushort s_mode { get; set; } = 0;

        /// <summary>
        /// S段时间，范围0~1S
        /// </summary>
        public double s_Para { get; set; } = 0.2;
        #endregion

        #region 设置单轴运动速度曲线
        /// <summary>
        /// 起始速度
        /// </summary>
        public double Min_Vel { get; set; } = 10;
        /// <summary>
        /// 最大速度
        /// </summary>
        public double Max_Vel { get; set; } = 20;
        /// <summary>
        /// 停止速度
        /// </summary>
        public double Stop_Vel { get; set; } = 0;
        /// <summary>
        /// 减速度
        /// </summary>
        public double STdec { get; set; } = 0.1;

        /// <summary>
        /// 加速度
        /// </summary>
        public double STacc { get; set; } = 0.1;
        #endregion

        #region 实际运动参数
        /// <summary>
        /// 起始速度
        /// </summary>
        public double Jog_Min_Vel { get; set; } = 1;
        /// <summary>
        /// 最大速度
        /// </summary>
        public double Jog_Max_Vel { get; set; } = 20;
        /// <summary>
        /// 减速度
        /// </summary>
        public double Jog_Tdec { get; set; } = 0.1;

        /// <summary>
        /// 加速度
        /// </summary>
        public double Jog_Tacc { get; set; } = 0.1;
        #endregion

        /// <summary>
        /// 外部编码器输入类型
        /// </summary>
        public ushort IptMode { get; set; }
        /// <summary>
        /// 轴脉冲输出模式
        /// </summary>
        public ushort OutMode { get; set; } = 0;

        #region 极性
        /// <summary>
        /// 原点极性 零常开 非零常闭
        /// </summary>
        public int Polarity { get; set; } = 1;

        /// <summary>
        /// 轴脉冲极性
        /// </summary>
        public bool Pulse_Pol { get; set; }

        /// <summary>
        /// 轴脉冲方向极性
        /// </summary>
        public bool Dir_Pol { get; set; }

        /// <summary>
        /// 编码器方向极性
        /// </summary>
        public int Enc_Pol { get; set; }

        /// <summary>
        /// Z编码器方向极性
        /// </summary>
        public int EncZ_Pol { get; set; }
        /// <summary>
        /// 正限位极性
        /// </summary>
        public int Plimit_Pol { get; set; }
        /// <summary>
        /// 负限位极性
        /// </summary>
        public int Nlimit_Pol { get; set; }
        #endregion

        #region 使能
        /// <summary>
        /// 伺服报警使能
        /// </summary>
        public bool Enable_AxisAlarm { get; set; }
        /// <summary>
        /// 正极限使能
        /// </summary>
        public bool Enable_Plimit { get; set; }
        /// <summary>
        /// 负极限使能
        /// </summary>
        public bool Enable_Nlimit { get; set; }
        #endregion
        #region 软极限
        /// <summary>
        /// 正软限位
        /// </summary>
        public long SPostiveLimitedP { get; set; } = 99999999;
        /// <summary>
        /// 负软限位
        /// </summary>
        public long SNeativeLimitedP { get; set; } = -99999999;
        #endregion
    }
}
